package com.liuyjy2.encryptDecrypt;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
import com.liuyjy.base.common.util.AESUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;

import java.io.IOException;
import java.util.Base64;

/**
 * @Author liuyjy
 * @Date 2025/2/20 9:42
 * @Description:  动态序反序列化器
 **/
@Slf4j
public class DynamicCryptoDeserializer extends JsonDeserializer<Object> {
    @Override
    public Object deserialize(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt) throws IOException {
        // 解密逻辑，假设是简单的Base64解码
        return AESUtil.decrypt(p.getText());
    }
}